package com.eblacorp.archive.security;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.context.SecurityContextHolder;
/**
 * @author Mahmoud.Ezzat
 * 
 */
@ManagedBean
@SessionScoped
public class UserBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5070281633486602238L;
	
	
	public Boolean getIsAdmin() {
		return AuthorityUtils
				.authorityListToSet(SecurityContextHolder.getContext()
						.getAuthentication().getAuthorities()).contains("ROLE_ARCH_ADMIN");
	}
	
	public Boolean getIsViewer() {
		return AuthorityUtils
				.authorityListToSet(SecurityContextHolder.getContext()
						.getAuthentication().getAuthorities()).contains("ROLE_ARCH_VIEWER");
	}
	
	public Boolean getIsDataEntry(){
		return AuthorityUtils
				.authorityListToSet(SecurityContextHolder.getContext()
						.getAuthentication().getAuthorities()).contains("ROLE_ARCH_DATA_ENTRY");
	}
	
	public Boolean getIsSuperViewer(){
		return AuthorityUtils
				.authorityListToSet(SecurityContextHolder.getContext()
						.getAuthentication().getAuthorities()).contains("ROLE_ARCH_SUPER_VIEWER");
	}
	
	public Boolean getIsManager(){
		return AuthorityUtils
				.authorityListToSet(SecurityContextHolder.getContext()
						.getAuthentication().getAuthorities()).contains("ROLE_ARCH_MANAGER");
	}
}
